namespace Sage.Http.Models
{
    /// <summary>
    /// API速率限制信息
    /// </summary>
    public class RateLimitInfo
    {
        /// <summary>
        /// 速率限制的最大请求数
        /// </summary>
        public int? Limit { get; set; }

        /// <summary>
        /// 剩余可用请求数
        /// </summary>
        public int? Remaining { get; set; }

        /// <summary>
        /// 速率限制重置时间
        /// </summary>
        public DateTimeOffset? ResetTime { get; set; }

        /// <summary>
        /// 获取距离重置时间的剩余秒数
        /// </summary>
        public int? SecondsUntilReset => ResetTime.HasValue
            ? (int)Math.Max(0, (ResetTime.Value - DateTimeOffset.UtcNow).TotalSeconds)
            : null;

        /// <summary>
        /// 检查是否已达到速率限制
        /// </summary>
        public bool IsLimitReached => Remaining.HasValue && Remaining.Value <= 0;
    }
}